package org.cloudfoundry.samples.domain;

public enum CustomerType {
    MANAGER(99, "管理用户", 60),
    VIP(30, "VIP用户", 15), 
    Register(20, "注册用户", 8),
    normal(10, "未注册用户", 5);

    private final int level;

    private final String code;

    private final int min;

    private CustomerType(int level, String code, int min) {
        this.level = level;
        this.min = min;
        this.code = code;
    }

    public static int getLevel(String code) {
        for (CustomerType c : CustomerType.values()) {
            if (c.getCode().equals(code)) {
                return c.level;
            }
        }

        return 10;
    }

    public static int getMin(int level) {
        for (CustomerType c : CustomerType.values()) {
            if (c.getLevel() == level) {
                return c.min;
            }
        }

        return 3;
    }

    public String getCode() {
        return code;
    }

    public int getLevel() {
        return level;
    }

    public int getMin() {
        return min;
    }


}
